package queueddas;

import java.awt.*;
import java.util.Random;
import javax.swing.*;

public class Costumer{

    //private int dx;
    //private int dy;
    private int x;
    private int y;
    private int isOnMap;
    private Object isAtTableNum;
    private Object isAtSeatLet;
    private Object order;
    private Image image;

    public Costumer(){
        int imagerand;
        Random rand = new Random();
        String costumerImage = "costumer_smith.gif";
        if((imagerand = rand.nextInt() % 4) <= 0)
            imagerand *= -1;
        
        switch(imagerand){
            case 0: costumerImage = "costumer_gypsy.gif"; break;
            case 1: costumerImage = "costumer_smith.gif"; break;
            case 2: costumerImage = "costumer_minstrel.gif"; break;
            case 3: costumerImage = "costumer_paladin.gif"; break;
        }

        ImageIcon ii = new ImageIcon(costumerImage);
        image = ii.getImage();
        x = 770;
        y = 490;

        order = "-1";
    }

    public int getX(){
        return x;
    }

    public int getY(){
        return y;
    }

    public Object createOrder(){
        Random rand = new Random();
        int r = rand.nextInt() % 2;
               
        if(r < 0)
            r *= -1;

        if(r == 0)
            order = "1";
        else
            order = "2";

        return order;
    }

    public int myOrder(Object order){
        if(this.order == order)
            return 1;
        else
            return 0;
    }

    public void setXY(int x, int y){
            this.x = x;
            this.y = y;
    }
    

    public void changePos(Object tableNum, Object seatLett){
       
        if(tableNum == "-"){
            x = ((2*x)/2); y = ((2*y)/2);//print error message
        }
        else if(tableNum == "1"){
           if(seatLett == "B"){
                x = 430; y = 270;
            }
           else{
                x = 300; y = 270;
           }
       }

        else if(tableNum == "2"){
            if(seatLett == "B"){
                x = 620; y = 270;
            }
           else{
                x = 490; y = 270;
           }
        }

        else if(tableNum == "3"){
            if(seatLett == "B"){
                x = 810; y = 270;
            }
           else{
                x = 680; y = 270;
           }
        }

        else if(tableNum == "4"){
            if(seatLett == "B"){
                x = 430; y = 430;
            }
            else{
                x = 300; y = 430;
            }
        }
        else if(tableNum == "5"){
            if(seatLett == "B"){
                x = 620; y = 430;
            }
            else{
                x = 490; y = 430;
            }
        }
        defineSeat(tableNum, seatLett);
    }
        

    public void defineSeat(Object isAtTableNum, Object isAtSeatLet){
        this.isAtTableNum = isAtTableNum;
        this.isAtSeatLet = isAtSeatLet;
    }
    
    public int imAtThisTable(){
        int tableNum = 0;

        if(isAtTableNum == "1")
               tableNum = 0;
               else if(isAtTableNum == "2")
               tableNum = 1;
               else if(isAtTableNum == "3")
               tableNum = 2;
               else if(isAtTableNum == "4")
               tableNum = 3;
               else if(isAtTableNum == "5")
               tableNum = 4;

        return tableNum;
    }

    public int imAtThisSeat(){
        int seatLet = -1;

        if(isAtSeatLet == "A")
            seatLet = 0;
        else
            seatLet = 1;

        return seatLet;
    }



    public Image getImage() {
        return image;
    }
}
